package com.legoo.studaychineseonline.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
 * 正则工具
* */
public class RegularUtil {
    public static boolean isTelUserName(String value) {
        if (value != null ) {
            Pattern pattern = Pattern.compile("^[a-zA-Z0-9_]{4,18}$");
            Matcher matcher = pattern.matcher(value);
            return matcher.matches();
        }
        return false;
    }
    //判断email格式是否正确
    public static boolean isEmail(String email) {
        if (email != null ) {
            String str = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
            Pattern p = Pattern.compile(str);
            Matcher m = p.matcher(email);

            return m.matches();
        }
        return false;
    }
}
